﻿package mortal.game.view.common.guide.stepOperater
{
    import flash.display.*;
    import flash.geom.*;
    import mortal.common.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.guide.data.*;
    import mortal.game.view.common.guide.navbar.*;
    import mortal.mvc.core.*;

    public class AutoGuideFlyToRightDownIcon extends AutoGuideStepBase implements IAutoGuideSteper
    {
        private var _flyEffect:AutoGuideFlyEffectSteper;
        private var _isFlyEnd:Boolean = false;
        private var _isTweenEnd:Boolean = false;

        public function AutoGuideFlyToRightDownIcon()
        {
            return;
        }// end function

        public function guide(param1:AutoGuideData, param2:Window = null) : void
        {
            if (_working)
            {
                this.stop();
            }
            _data = param1;
            if (_data.clickChildName == AutoGuideClickType.SaveRightDownIconShowed)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, param1));
                return;
            }
            var _loc_3:* = param1.guideTypeValue as String;
            this._flyEffect = GameController.autoGuide.flyEffectSteper as AutoGuideFlyEffectSteper;
            var _loc_4:* = NavbarButtonUIRow.instance.getCurPlace(_loc_3);
            var _loc_5:* = new AutoGuideData();
            _loc_5.guideTypeValue = int(_loc_4.x + 22).toString() + "," + int(_loc_4.y + 22).toString();
            _loc_5.mainId = -11111;
            _loc_5.stepId = -1;
            this._flyEffect.guide(_loc_5);
            this._flyEffect.preEndCallback = this.startIconTween;
            this._flyEffect.endCallback = this.flyEnd;
            this._isFlyEnd = false;
            this._isTweenEnd = false;
            var _loc_6:* = DisplayUtil.getChildByPropety(GameController.navbar.view as DisplayObjectContainer, "name", _loc_3);
            super.setData(param1, null, _loc_6);
            return;
        }// end function

        private function flyEnd() : void
        {
            this._isFlyEnd = true;
            this.checkStop();
            return;
        }// end function

        private function startIconTween() : void
        {
            NavbarButtonUIRow.instance.tweenShowIcon(_data.guideTypeValue as String, this.iconShowEnd);
            return;
        }// end function

        private function iconShowEnd() : void
        {
            this._isTweenEnd = true;
            this.checkStop();
            return;
        }// end function

        private function checkStop() : void
        {
            if (!this._isFlyEnd || !this._isTweenEnd)
            {
                return;
            }
            this.stop(_data);
            return;
        }// end function

        override public function stop(param1:AutoGuideData = null) : void
        {
            super.stop(param1);
            if (param1 != null)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, param1));
            }
            return;
        }// end function

    }
}
